//
//  MHHistoryListViewController.m
//  MHO
//
//  Created by Hien NV on 12/15/14.
//  Copyright (c) 2014 maihoang. All rights reserved.
//

#import "MHHistoryListViewController.h"
#import "HistoryTransactionViewController.h"

@interface MHHistoryListViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, weak) IBOutlet UITableView* tableView;
@property (nonatomic, strong) NSArray* data;
@end

@implementation MHHistoryListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.data = @[
                  @"Chuyển tiền vào game",
                  @"% từ ID cấp dưới",
                  @"Chuyển tiền cá nhân",
                  @"Nạp gold"];
    
    [[self.navibarView leftButton] setImage:[UIImage imageNamed:@"btn_back"] forState:UIControlStateNormal];
    [[self.navibarView leftButton] setImage:[UIImage imageNamed:@"btn_back_focus"] forState:UIControlStateHighlighted];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - TableView Data Source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.data.count;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] init];
    }
    [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    cell.contentView.backgroundColor = [UIColor viewFlipsideBackgroundColor];
    cell.backgroundColor = [UIColor viewFlipsideBackgroundColor];
    
    [cell.textLabel setText:self.data[indexPath.row]];
    [cell.textLabel setTextColor:[UIColor whiteColor]];
    
    return cell;
}

#pragma mark - Table View Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    HistoryTransactionViewController* vc = [[HistoryTransactionViewController alloc] initWithNibName:@"HistoryTransactionViewController" bundle:nil];
    vc.index = indexPath.row;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
